/**
 * 
 */
package orz.mikeneck.event.atnd;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

import orz.mikeneck.event.Query;
import orz.mikeneck.event.QueryFormat;

/**
 * @author mike_neck
 *
 */
public class AtndEventSearchQuery implements
	Query, AtndEventSearchInterface {

	@QueryFormat(value = 10,queryParam = "event_id")
	private long eventId;

	@QueryFormat(value = 20, queryParam = "keyword")
	private String keyword;

	@QueryFormat(value = 30, queryParam = "keyword_or")
	private ArrayList<String> keywords;

	@QueryFormat(value = 40, queryParam = "ym")
	private String yyyymm;

	@QueryFormat(value = 50, queryParam = "ymd")
	private String yyyymmdd;

	@QueryFormat(value = 60, queryParam = "user_id")
	private long userId;

	@QueryFormat(value = 70, queryParam = "nickname")
	private String nickname;

	@QueryFormat(value = 80, queryParam = "twitter_id")
	private long twitterId;

	@QueryFormat(value = 90, queryParam = "owner_id")
	private long ownerId;

	@QueryFormat(value = 100, queryParam = "owner_nickname")
	private String ownerNickname;

	@QueryFormat(value = 110, queryParam = "owner_twitter_id")
	private long ownerTwitterId;

	@QueryFormat(value = 120, queryParam = "start")
	private int start;

	@QueryFormat(value = 130, queryParam = "count")
	private int count;

	@QueryFormat(value = 140, queryParam = "format")
	private final String format = "json";

	/**
	 * Get event id.
	 * @return eventId
	 */
	public long getEventId() {
		return this.eventId;
	}

	/**
	 * @see orz.mikeneck.event.Query#getQueryString()
	 */
	@Override
	public String getQueryString() {
		return null;
	}

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setEventId(long)
     */
    @Override
    public
        void setEventId(long id) {
	    this.eventId = id;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setKeyword(java.lang.String)
     */
    @Override
    public
        void setKeyword(String keyword) {
	    this.keyword = keyword;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setKeywordOr(java.lang.String[])
     */
    @Override
    public
        void setKeywordOr(String... keywords) {
	    this.keywords = new ArrayList<String>(Arrays.asList(keywords));
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setYm(java.lang.String)
     */
    @Override
    public
        void setYm(String yyyymm) {
    	this.yyyymm = yyyymm;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setYmd(java.lang.String)
     */
    @Override
    public
        void setYmd(String yyyymmdd) {
    	this.yyyymmdd = yyyymmdd;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setUserId(long)
     */
    @Override
    public
        void setUserId(long id) {
    	this.userId = id;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setNickname(java.lang.String)
     */
    @Override
    public
        void setNickname(String nickname) {
    	this.nickname = nickname;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setTwitterId(long)
     */
    @Override
    public
        void setTwitterId(long twitterId) {
    	this.twitterId = twitterId;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setOwnerId(long)
     */
    @Override
    public
        void setOwnerId(long ownerId) {
    	this.ownerId = ownerId;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setOwnerNickname(java.lang.String)
     */
    @Override
    public
        void setOwnerNickname(String nickname) {
    	this.ownerNickname = nickname;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setOwnerTwitterId(long)
     */
    @Override
    public
        void setOwnerTwitterId(long ownerTwitterId) {
    	this.ownerTwitterId = ownerTwitterId;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setStart(int)
     */
    @Override
    public
        void setStart(int start) {
	    this.start = start;
    }

	/**
     * @see orz.mikeneck.event.atnd.AtndEventSearchInterface#setCount(int)
     */
    @Override
    public
        void setCount(int count) {
    	this.count = count;
    }

	/**
     * @return the keywords
     */
    public
        String getKeywords() {
    	if(this.keywords.size() > 0){
    		StringBuffer sb = new StringBuffer();
    		for(Iterator<String> item = this.keywords.iterator(); item.hasNext();){
    			sb.append(item.next());
    			if(item.hasNext())
    				sb.append(",");
    		}
    		return sb.toString();
    	}else{
    		return "";
    	}
    }

	/**
     * @return the ownerNickname
     */
    public
        Object getOwnerNickName() {
    	return ownerNickname;
    }

	/**
     * @param nickname the ownerNickname to set
     */
    public
        void setOwnerNickName(String nickname) {
    	this.ownerNickname = nickname;
    }

	/**
     * @return the keyword
     */
    public
        String getKeyword() {
    	return keyword;
    }

	/**
     * @return the yyyymm
     */
    public
        String getYm() {
    	return yyyymm;
    }

	/**
     * @return the yyyymmdd
     */
    public
        String getYmd() {
    	return yyyymmdd;
    }

	/**
     * @return the userId
     */
    public
        long getUserId() {
    	return userId;
    }

	/**
     * @return the nickname
     */
    public
        String getNickname() {
    	return nickname;
    }

	/**
     * @return the twitterId
     */
    public
        long getTwitterId() {
    	return twitterId;
    }

	/**
     * @return the ownerId
     */
    public
        long getOwnerId() {
    	return ownerId;
    }

	/**
     * @return the ownerTwitterId
     */
    public
        long getOwnerTwitterId() {
    	return ownerTwitterId;
    }

	/**
     * @return the start
     */
    public
        int getStart() {
    	return start;
    }

	/**
     * @return the count
     */
    public
        int getCount() {
    	return count;
    }

	/**
     * @return the format
     */
    public
        String getFormat() {
    	return format;
    }

}
